/*
 * Location.java
 * 
 * Created on 27.11.2007, 18:24:23
 * 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cz.possoft.serializable.generic;

import java.io.Serializable;

/**
 *
 * @author mara
 * 
 * Predstavuje umisteni na sachovnici
 */
public class Location implements Serializable {
	
	public static final long serialVersionUID = 100458732;
    
    private int x,y;

    public Location(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }
        
    public String toString() {        
        return "[" + x + ", " + y + "]";
    }
    
    // pro lokaci 0,0 vraci true
    public boolean isNull() {
        return ((x == -1) && (y == -1));                
    }
    
    public Location setNull() {
        x = -1;
        y = -1;
        return this;
    }
    
    
    public boolean equals(Object o) {
        Location l = (Location)o;
        if ((l.getX() == getX()) && (l.getY() == getY())) return true;
        return false;
    }
    
    
    public int hashCode() {
        return getX()*800 + getY();
    }

}
